import pymysql
from aestate.dbs._mysql import tag
from aestate.work.Config import MySqlConfig
from aestate.work.Manage import Pojo

pymysql.install_as_MySQLdb()


class DatabaseConfig(MySqlConfig):
    def __init__(self):
        self.set_field('print_sql', True)
        self.set_field('last_id', True)
        super(DatabaseConfig, self).__init__(
            # 数据库地址
            host='localhost',
            port=3306,
            database='sotd',
            user='root',
            password='123456',
            db_type='pymysql')


class table_template(Pojo):
    def __init__(self, **kwargs):
        """
        模板类对象
        """
        self.abst = True
        self.id = tag.intField(primary_key=True, auto_field=True, is_null=False, comment='主键自增')
        self.create_time = tag.datetimeField(auto_time=True, is_null=False, comment='创建时间')
        self.update_time = tag.datetimeField(update_auto_time=True, is_null=False, comment='更新实际按')
        super(table_template, self).__init__(
            config_obj=DatabaseConfig(),
            log_conf={
                'path': "/cacode/sotd.cacode.ren/log/",
                'save_flag': True,
                'max_clear': 100
            },
            **kwargs)
